package com.cts.rt.service;

import java.util.List;

import org.springframework.security.core.userdetails.UsernameNotFoundException;

import com.cts.rt.dao.EmployeeDao;
import com.cts.rt.model.Employee;

/**
 * Business Service Interface to handle communication between web and
 * persistence layer.
 * 
 * @author <a href="mailto:matt@raibledesigns.com">Matt Raible</a> Modified by
 *         <a href="mailto:dan@getrolling.com">Dan Kibler </a>
 */
public interface EmployeeManager extends GenericManager<Employee, Long> {
	/**
	 * Convenience method for testing - allows you to mock the DAO and set it on
	 * an interface.
	 * 
	 * @param userDao
	 *            the UserDao implementation to use
	 */
	void setEmployeeDao(EmployeeDao employeeDao);

	/**
	 * Retrieves a user by userId. An exception is thrown if user not found
	 * 
	 * @param userId
	 *            the identifier for the user
	 * @return User
	 */
	Employee getEmployee(String userId);

	/**
	 * Finds a user by their username.
	 * 
	 * @param username
	 *            the user's username used to login
	 * @return User a populated user object
	 * @throws org.springframework.security.core.userdetails.UsernameNotFoundException
	 *             exception thrown when user not found
	 */
	Employee getUserByUsername(String employeename)
			throws UsernameNotFoundException;

	/**
	 * Retrieves a list of all users.
	 * 
	 * @return List
	 */
	List<Employee> getEmployees();

	/**
	 * Saves a user's information.
	 * 
	 * @param user
	 *            the user's information
	 * @throws UserExistsException
	 *             thrown when user already exists
	 * @return user the updated user object
	 */
	Employee saveEmployee(Employee employee) throws UserExistsException;

	/**
	 * Removes a user from the database
	 * 
	 * @param user
	 *            the user to remove
	 */
	void removeEmployee(Employee employee);

	/**
	 * Removes a user from the database by their userId
	 * 
	 * @param userId
	 *            the user's id
	 */
	void removeEmployee(String id);

	/**
	 * Search a user for search terms.
	 * 
	 * @param searchTerm
	 *            the search terms.
	 * @return a list of matches, or all if no searchTerm.
	 */
	List<Employee> search(String searchTerm);
}
